#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i,n) for (int i=0; i<n; i++)

#define TRACE(x...) 
#define PRINT(x...) TRACE(printf(x))

bool primes[100010];

void sieve() {
	int p=2;

	rep(i,100000) primes[i]=true; 

	while (p*p<=(100000)) {
		for (int i=2; i*p<=100000; i++)
			primes[i*p]=false;

		while (!primes[++p]) {
			if (p*p>100000) break;
		}
	}
}

int n;
int num;
int tmp;
int lim;
int pfacts[100];
int pfactpow[100];
int tmpExp[100];
int fl;
int nFact;
int divs[150];
int nDiv;

void recDivisors(int n) {
	if (n==nFact) {
		divs[nDiv]=1;

		rep(i,n) {
			rep(j, tmpExp[i]) divs[nDiv]*=pfacts[i];
		}

		nDiv++;
		return;
	}

	for (tmpExp[n]=0; tmpExp[n]<=pfactpow[n]; tmpExp[n]++)
		recDivisors(n+1);
}

int main() {
	sieve();

	printf("PERFECTION OUTPUT\n");

	while (1) {
		scanf("%d", &num);
		if (!num) break;
		printf("%5d  ", num);

		lim = sqrt(num)+1;
		tmp=num;
		nDiv=0;
		nFact=0;

		for (int i=2; i<=lim; i++) {
			if (tmp%i==0 && primes[i]) {
				pfacts[nFact]=i;
				pfactpow[nFact]=1;
				tmp/=i;

				while (tmp%i==0) {
					tmp/=i;
					pfactpow[nFact]++;
				}

				nFact++;
			}
		}
		
		if (tmp!=1) {		
			pfacts[nFact]=tmp;
			pfactpow[nFact++]=1;
		}
	
		PRINT("\nFacts for %d: ", num);

		TRACE(
			for (int i=0; i<nFact; i++)
				printf("%d^%d ", pfacts[i], pfactpow[i]);
			printf("\n"); 
		);

		rep(i,nFact) tmpExp[i]=0;

		recDivisors(0);
		
		TRACE(
			printf("Divs: ");
			rep(i,nDiv) printf("%d ", divs[i]);
			printf("\n");
		);

		int sum = 0;

		rep(i,nDiv) if (divs[i]<num) sum+=divs[i];
		
		if (sum==num) printf("PERFECT\n");
		else {
			if (sum<num) printf("DEFICIENT\n");
			else printf("ABUNDANT\n");
		}
	}

	printf("END OF OUTPUT\n");

	return 0;
}
